Viewing a file

back to section start!
 
  If you've double-clicked on a file or selected a file and used one of the 
view commands, (read, show, play, etc), then you'll end up in this routine. 
  Basically, it extracts the file to T: and then performs the specified 
function on it. 
 
  1viewsingle: 
  2  lister set handle busy on 
  3  lister set handle title getcatstr(10,'Extracting from archive...') 
  4  lister refresh handle full 
  5 
  6  select 
  7    when arctype = 'LHA' then 
  8      address command 'LhA e -q -x2 -X -Qo "'patch(arcfile,0)'" T: "'patch(arcsubdir||namestr,1)'"' 
  9    when arctype = 'LZX' then 
 10      address command 'LZX e -q -X0 --' lzxkludge(patch(arcfile,0)) 'T:' lzxkludge(patch(arcsubdir||namestr,0)) 
 11    end 
 12 
 13  if rc > 0 then 
 14    call displayerror(getcatstr(11,'Error while extracting from archive.')) 
 15 
 16  /* some creative ARexx programming :-) */ 
 17  address command 'Run >NIL: <NIL: RX', 
 18    '"address' portname';', 
 19    'thisfile = ''T:'namestr''';', 
 20    'command' event '''""''thisfile''""'';', 
 21    'command wait protect name ''""''thisfile''""'' set RWED;', 
 22    'do until ~exists(thisfile) | delete(thisfile);', 
 23      'call delay(200);', 
 24      'end"' 
 25 
 26  lister set handle title 'ArcDir:' arcname 
 27  lister refresh handle full 
 28  return 
 
Line: 
 1      Sub-routine label. 
 2      Make the lister busy so the user can't disturb us. 
 3      Call  getcatstr  for a message translation if required, 
        and put it in the lister titlebar. 
 4      Refresh the lister display using FULL so that the titlebar is also 
        updated. 
 6 - 11 Using a Select...When conditional block, we extract the file to T: 
        depending on whether it is an LZX or LhA archive. 
13 -14  If there was an error we call the  displayerror  routine to display 
        it passing along a translated message text if necessary. 
16 - 24 As Edmund says: 'Some creative ARexx programming' :)  But all this 
        block of statements really does is create the following script, 
        (assuming the file's name is 'foo.bar' and the action was 'Read'): 
 
        address 'DOPUS.1' 
        thisfile = 'T:foo.bar' 
        command Read "T:foo.bar" 
        command wait protect name "T:foo.bar" set RWED 
        do until ~exists("T:foo.bar") | delete("T:foo.bar") 
          call delay(200) 
        end 
 
  And what it does is call the action upon the file in T:, set it's 
protection bits to RWED, then loop around until either the file no longer 
exists or the file was successfully deleted. 
 
26 - 27 Set the lister titlebar back to it's usual display of the archive 
        name and refresh it so that the lister titlebar is updated. 
28      Back to where we came from. 
 

DOpus PLUS - giving you that bit extra...